home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
OpenDoc
/
Headline
/
Headline
/
DartmouthODUtils.cp
< prev
next >
Wrap
Text File
|
1995-04-27
|
1KB
|
57 lines
// OpenDoc utilities
// by Joe Francis and Jim Matthews
// Dartmouth College
#include <ODTypesB.xh>
#include <StorageU.xh>
#include <StorUtil.h>
#include "DartmouthODUtils.h"
//----------------------------------------------------------------------------------------
// SetValueEOF
//----------------------------------------------------------------------------------------
void SetValueEOF(Environment* ev, long theEOF, ODStorageUnit* su)
{
/* this doodad truncates a value in a storage unit at the appropriate point */
ODULong oldLength = su->GetSize(ev);
ODULong oldOffset = su->GetOffset(ev);
char junk[1];
if (oldLength<theEOF)
{
su->SetOffset(ev,oldLength);
StorageUnitSetValue(su, ev, theEOF-oldLength, junk);
su->SetOffset(ev,oldOffset);
}
else if (oldLength>theEOF)
{
su->SetOffset(ev,(ODULong)theEOF);
su->DeleteValue(ev, oldLength-theEOF);
oldOffset = (oldOffset>theEOF) ? theEOF : oldOffset;
su->SetOffset(ev,oldOffset);
}
}
//----------------------------------------------------------------------------------------
// SetODByteArray
//----------------------------------------------------------------------------------------
void SetODByteArray(long max, long len, void *data, ODByteArray *array)
{
array->_maximum = max;
array->_length = len;
array->_buffer = (octet *) data;
}
void *GetODByteArrayData(ODByteArray *array)
{
return (void *) array->_buffer;
}
long GetODByteArrayLen(ODByteArray *array)
{
return array->_length;
}